package com.qf.controller;


import com.qf.dto.Teaching;
import com.qf.entity.Comment;
import com.qf.entity.Student;
import com.qf.entity.Teacher;
import com.qf.entity.Transcript;
import com.qf.service.TeacherService;
import com.qf.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author qiankunquan
 */

@Controller
@RequestMapping("/teacher/")
public class TeacherController {
    @Autowired
    TeacherService teacherService;

    //录入成绩1 J
    @RequestMapping("add.do")
    @ResponseBody
    public R add(@RequestParam("snumber") String snumber, @RequestParam("courseId") int courseId) {
        return teacherService.entering(snumber, courseId);
    }

    //录入成绩2  J
    @RequestMapping("update.do")
    @ResponseBody
    public R update(String snumber,  int courseId,  int score) {
        return teacherService.giveScore(snumber, courseId, score);
    }

    //查看任教班级信息 J
    @RequestMapping("selectOne.do")
    @ResponseBody
    public R selectOne(HttpSession session) {
        String tnumber = (String) session.getAttribute("userId");
        return teacherService.selectOne(tnumber);
    }

    //查看评教结果 J
    @RequestMapping("selectComment.do")
    @ResponseBody
    public R selectComment(HttpSession session, @RequestParam("courseId") int courseId) {
        String tnumber = (String) session.getAttribute("userId");
        return new R(0, "sucess", teacherService.selectComment(tnumber, courseId));
    }

    @GetMapping("selectTeacherInfo.do")
    @ResponseBody
    public R selectStudentInfo(int id) {
        return teacherService.selectTeacherInfo(id);
    }

    // 查看个人监考 J
    @RequestMapping("selectInvigilation.do")
    @ResponseBody
    public R selectInvigilation(HttpSession session) {
        String tnumber = (String) session.getAttribute("userId");
        return teacherService.selectInvigilation(tnumber);
    }

    // 查看个人课程表 J
    @RequestMapping("selectSchedule.do")
    @ResponseBody
    public R selectSchedule(HttpSession session) {
        String tnumber = (String) session.getAttribute("userId");
        return teacherService.selectSchedule(tnumber);
    }
//    老师开启或关闭课程签到 J
    @RequestMapping("openCloseSignIn.do")
    @ResponseBody
    public R openCloseSignIn(HttpSession session, int courseId) {
        String tnumber = (String) session.getAttribute("userId");
        return teacherService.openCloseSignIn(tnumber, courseId);
    }

    @RequestMapping("selectTeacher.do")
    @ResponseBody
    public R selectTeacher(String status,HttpSession session){
        String snumber = (String) session.getAttribute("userId");
        return teacherService.selectTeacher(status,snumber);
    }

}
